import { EffectsCommandMap } from 'dva';
import { getTodoList } from './service';
export interface ITotoState {
  id: string;
  complate: boolean;
  value: string;
}

interface ITodoListModel {
  namespace: 'todoList';
  state: ITotoState[];
  reducers: {
    setTodoList(
      state: ITotoState[],
      action: { payload: ITotoState },
    ): ITotoState[];
  };
  effects: {
    getTodoListAsync(action: {}, effects: EffectsCommandMap): Generator;
  };
}

const todoList: ITodoListModel = {
  namespace: 'todoList',
  state: [],
  reducers: {
    setTodoList(state, action) {
      return {
        ...state,
      };
    },
  },
  effects: {
    *getTodoListAsync(action, { call, put, select }) {
      const result = yield call(getTodoList);
      console.log('todolist', result);
    },
  },
};

export default todoList;
